using System;
using System.Runtime.InteropServices;

namespace NTrace
{
    internal struct TraceGuidRegistration
    {
        private IntPtr guid;
        private ulong handle;

        public static TraceGuidRegistration Create(Guid guid)
        {
            TraceGuidRegistration output = new TraceGuidRegistration();
            output.guid = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(Guid)));
            Marshal.StructureToPtr(guid, output.guid, false);
            return output;
        }

        public Guid Guid
        {
            get
            {
                Guid output = (Guid)Marshal.PtrToStructure(this.guid, typeof(Guid));
                return output;
            }
        }

        public ulong Handle
        {
            get
            {
                return this.handle;
            }
        }
    }
}